﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;

namespace Pavilion.DesignerTool.ViewTools.ConnectableListBox
{
    public class NodeBaseWrapper : IConnectableItem
    {
        public NodeBase Node { get; set; }
        public ContainerNodeWrapper ParentContainerNodeWrapper { get; set; }
        public NotifiableCollection<GameDataWrapper> GameDataWrapperCollection { get; private set; }
        public object Data { get { return Node; } }
        public Point Position { get; set; }
        public string Name { get { return Node.Name; } set { Node.Name = value; } }

        public NodeBaseWrapper(NodeBase node)
        {
            this.Node = node;
            GameDataWrapperCollection = new NotifiableCollection<GameDataWrapper>();
            this.Position = new Point(0, 0);

            foreach (GameData gameData in node.GameDataCollection)
                GameDataWrapperCollection.Add(new GameDataWrapper(gameData));
        }

        internal void AddGameData(GameDataWrapper gameDataWrapper)
        {
            Node.GameDataCollection.Add(gameDataWrapper.GameData);
            GameDataWrapperCollection.Add(gameDataWrapper);
        }

        internal void RemoveGameData(GameDataWrapper gameDataWrapper)
        {
            Node.GameDataCollection.Remove(gameDataWrapper.GameData);
            GameDataWrapperCollection.Remove(gameDataWrapper);
        }
    }
}
